package com.gxgeek.rabbitmqspring;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

import static com.gxgeek.rabbitmqspring.RabbitMqConfig.QUEUENAME;

/**
 * @author gaoxing
 * @create 2018-05-17 下午3:20
 */
@Component

public class Sender {

    @Autowired

    private AmqpTemplate rabbitMQTemplate;


    public void send() {

        String context = "hello :" + new Date();

        System.out.println("Sender : " + context);

        this.rabbitMQTemplate.convertAndSend(QUEUENAME, context);

    }

}

